//$(document).ready(function () {
document.addEventListener('DOMContentLoaded', function () {
    $("body").iealert();
    if ('undefined' == typeof sessionStorage.isVisite) {
        sessionStorage.isVisite = 1
    }
    if (!sessionStorage.isVisite) {
    }
    $('#fullpage').fullpage({
        anchors: ["1", "2", "3", "4", "5", "6", "7"],
        navigation: true,
        navigationPosition: "right",
        afterRender: function () {
            //playing the video
            $('video').get(0).play();
        },
        afterLoad: function (anchorLink, index) {
            function title() {
                $('.piti .titie_1').animate({top: 0, opacity: 1}, 1000, 'easeOutQuint');
                $('.piti .titie_2').delay(200).animate({marginLeft: '-133px', opacity: 1}, 1000, 'easeOutCirc');
            }

            if (index == 2) {
                title()
                $('.piti .titie_3').delay(300).animate({left: '50%', opacity: 1}, 1000, 'easeOutExpo');
                $('.introduction_bottom #p1').stop().delay(500).animate({
                    paddingTop: '40px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('.introduction_bottom #p2').stop().delay(700).animate({
                    paddingTop: '20px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('.introduction_bottom #p3').stop().delay(900).animate({
                    paddingTop: '20px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('.introduction_bottom .more').stop().delay(1100).animate({
                    paddingTop: '26px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('#open_more').click(function () {
                    $('.more_show').fadeIn();
                    $(document).on('wheel', function () {
                        return false;    //禁止鼠标滑轮事件
                    })
                })
                $('#more_close').click(function () {
                    $('.more_show').fadeOut();
                    $(document).unbind();  //关闭之后移除事件
                })
            }
            if (index == 3) {
                title()
                $('#section3 .piti .titie_3').stop().delay(300).animate({left: '50%', opacity: 1}, 1000, 'easeOutExpo');
                $('.Project_one .Primg').stop().delay(500).animate({
                    marginLeft: '0px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('.Project_one .Pr_mask').stop().delay(500).animate({left: '0px', opacity: 0.3}, 1000, 'easeOutQuint');
                $('.Project_one .Pra1').stop().delay(600).animate({top: '50%', opacity: 1}, 1000, 'easeOutQuint');
                $('.Project_one .Prtxt1').stop().delay(700).animate({top: '70%', opacity: 1}, 1000, 'easeOutQuint');
                $('.Project_two .Primg2').stop().delay(900).animate({
                    marginLeft: '0px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('.Project_two .Pr_mask').stop().delay(900).animate({left: '0px', opacity: 0.3}, 1000, 'easeOutQuint');
                $('.Project_two .Prtxt2').stop().delay(1000).animate({top: '50%', opacity: 1}, 1000, 'easeOutQuint');
                $('.Project_two .Prtxt3').stop().delay(1100).animate({top: '60%', opacity: 1}, 1000, 'easeOutQuint');
                $('.Project_three .Primg3').stop().delay(1300).animate({
                    marginTop: '0px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('.Project_three .Pr_mask').stop().delay(1300).animate({
                    top: '0px',
                    opacity: 0.3
                }, 1000, 'easeOutQuint');
                $('.Project_three .Prtxt4').stop().delay(1400).animate({top: '34px', opacity: 1}, 1000, 'easeOutQuint');
                $('.Project_right .Project_four').stop().delay(1600).animate({
                    right: '0',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('.Project_four .Pra1').stop().delay(1700).animate({top: '50%', opacity: 1}, 1000, 'easeOutQuint');
                $('.Project_four .Prtxt5').stop().delay(1800).animate({top: '70%', opacity: 1}, 1000, 'easeOutQuint');
            }
            if (index == 4) {
                title()
                $('#section4 .piti .titie_3').stop().delay(300).animate({left: '50%', opacity: 1}, 1000, 'easeOutExpo');
                $('.Team_member .swiper-container .swiper-wrapper').stop().delay(500).animate({
                    marginTop: "0px", opacity: 1
                }, 1000, 'easeOutQuint');
                // $('.Team_member .swiper-container .swiper-wrapper .swiper-slide .swiper_text').stop().delay(900).animate({
                //     marginTop:'0px', opacity:1
                // },1000 ,'easeOutQuint');
                $('.Team_member .swiper-container .swiper-button-prev').stop().delay(700).animate({
                    top: '159px', opacity: 0.5
                }, 1000, 'easeOutQuint');
                $('.Team_member .swiper-container .swiper-button-next').stop().delay(700).animate({
                    top: '159px', opacity: 0.5
                }, 1000, 'easeOutQuint');
            }
            if (index == 5) {
                title()
                $('#section5 .piti .titie_3').stop().delay(300).animate({left: '50%', opacity: 1}, 1000, 'easeOutExpo');
                $('.Media_center .Media_left .Media_img').stop().delay(500).animate({
                    marginLeft: '0px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('.Media_center .Media_left .Media_text').stop().delay(700).animate({
                    marginTop: '0px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('.Media_center .Media_middle .Media_text').stop().delay(900).animate({
                    marginTop: '0px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('.Media_center .Media_middle .Media_img').stop().delay(1100).animate({
                    marginTop: '0px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('.Media_center .Media_right .Media_img').stop().delay(1300).animate({
                    marginLeft: '0px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
                $('.Media_center .Media_right .Media_text').stop().delay(1500).animate({
                    marginTop: '0px',
                    opacity: 1
                }, 1000, 'easeOutQuint');
            }
            if (index == 6) {
                title()
                $('#section6 .piti .titie_3').stop().delay(300).animate({left: '50%', opacity: 1}, 1000, 'easeOutExpo');
                $('.Photo_bottom span').stop().delay(500).animate({width: '100%', right: 0}, 1000, 'easeOutExpo');
                var swiper = new Swiper('.photobox .swiper-container', {
                    slidesPerView: 'auto',
                    centeredSlides: true,
                    paginationClickable: true,
                    spaceBetween: 120,
                    nextButton: '.swiper-button-next',
                    prevButton: '.swiper-button-prev',
                });
                $('.photobox .swiper-wrapper').stop().delay(700).animate({
                    marginLeft: '0',
                    opacity: 1
                }, 1000, 'easeOutExpo');
            }
            if (index == 7) {
                title()
                $('#section7 .piti .titie_3').stop().delay(300).animate({left: '50%', opacity: 1}, 1000, 'easeOutExpo');
                $('.contactbox .conta1').stop().delay(500).animate({
                    marginTop: '-10px',
                    opacity: 1
                }, 1000, 'easeInOutCubic');
                $('.contactbox .conta2').stop().delay(700).animate({
                    marginTop: '20px',
                    opacity: 1
                }, 1000, 'easeInOutCubic');
                $('.contactbox .conta3').stop().delay(900).animate({
                    marginTop: '20px',
                    opacity: 1
                }, 1000, 'easeInOutCubic');
                $('.contactbox .conta4').stop().delay(1100).animate({
                    marginTop: '20px',
                    opacity: 1
                }, 1000, 'easeInOutCubic');
                $('.contactbox .conta5').stop().delay(1300).animate({
                    marginTop: '20px',
                    opacity: 1
                }, 1000, 'easeInOutCubic');
                $('.contactbox .conta6').stop().delay(1500).animate({
                    marginTop: '10px',
                    opacity: 1
                }, 1000, 'easeInOutCubic');
                $('.contactbox .conta7').stop().delay(1700).animate({
                    marginTop: '20px',
                    opacity: 1
                }, 1000, 'easeInOutCubic');
                $('.contactbox .conta8').stop().delay(1900).animate({
                    marginTop: '20px',
                    opacity: 1
                }, 1000, 'easeInOutCubic');
                $('.contactbox .Copyright').stop().delay(2100).animate({
                    bottom: '20px',
                    opacity: 1
                }, 1000, 'easeInOutCubic');
            }
        },
        onLeave: function (index, direction) {
            function hide() {
                $('.piti .titie_1').stop(true,true).removeAttr('style');
                $('.piti .titie_2').stop(true,true).removeAttr('style');
            }

            if (index == 2) {
                hide()
                $('.piti .titie_3').stop(true,true).removeAttr('style');
                $('.introduction_bottom>*').stop(true,true).removeAttr('style');
            }
            if (index == 3) {
                hide()
                $('#section3 .piti .titie_3').stop(true,true).removeAttr('style');
                $('.Project_one a>div').stop(true,true).removeAttr('style');
                $('.Project_two a>div').stop(true,true).removeAttr('style');
                $('.Project_three a>div').stop(true,true).removeAttr('style');
                $('.Project_right .Project_four').stop(true,true).removeAttr('style');
                $('.Project_four a>div').stop(true,true).removeAttr('style');
            }
            if (index == 4) {
                hide()
                $('#section4 .piti .titie_3').stop(true,true).removeAttr('style');
                $('.Team_member .swiper-container .swiper-wrapper').stop(true,true).removeAttr('style');
                $('.Team_member .swiper-container .swiper-button-prev').stop(true,true).removeAttr('style');
                $('.Team_member .swiper-container .swiper-button-next').stop(true,true).removeAttr('style');
            }
            if (index == 5) {
                hide()
                $('#section5 .piti .titie_3').stop(true,true).removeAttr('style');
                $('.Media_left a>div').stop(true,true).removeAttr('style');
                $('.Media_middle a>div').stop(true,true).removeAttr('style');
                $('.Media_right a>div').stop(true,true).removeAttr('style');

            }
            if (index == 6) {
                hide()
                $('#section6 .piti .titie_3').stop(true,true).removeAttr('style');
                $('.Photo_bottom span').stop(true,true).removeAttr('style');
                $('.photobox .swiper-wrapper').stop(true,true).removeAttr('style');
            }
            if (index == 7) {
                hide()
                $('#section7 .piti .titie_3').stop(true,true).removeAttr('style');
                $('.contactbox>*').stop(true,true).removeAttr('style');
            }
        }
    });
    $('#menu_handler').click(function () {
        $('#Nav_Mask').slideDown();
    });
    $('#Nav_colse').click(function () {
        $('#Nav_Mask').slideUp();
    });
    if (!!+sessionStorage.isVisite) {
        sessionStorage.isVisite = 0
        $('.index_anmaite').show();
        if (!$('.anmaite_img').is(':animated')) {
            $('.anmaite_img .imga1').stop().delay(100).animate({
                marginTop: 0,
                opacity: 1
            }, 1000, 'easeOutBounce', function () {
                $(this).removeClass('anmaite_img').addClass('bgn').delay(1000).animate({
                    bottom: '-200px',
                    opacity: 0
                }, 1000, 'easeInOutElastic');
            });
            $('.anmaite_img .imga2').stop().delay(200).animate({
                bottom: 0,
                opacity: 1
            }, 1000, 'easeOutBounce', function () {
                $(this).removeClass('anmaite_img').addClass('bgn').delay(1200).animate({
                    top: '-200px',
                    opacity: 0
                }, 1000, 'easeInOutElastic');
            });
            $('.anmaite_img .imga3').stop().delay(300).animate({
                marginTop: 0,
                opacity: 1
            }, 1000, 'easeOutBounce', function () {
                $(this).removeClass('anmaite_img').addClass('bgn').delay(1300).animate({
                    bottom: '-200px',
                    opacity: 0
                }, 1000, 'easeInOutElastic');
            });
            $('.anmaite_img .imga4').stop().delay(400).animate({
                bottom: 0,
                opacity: 1
            }, 1000, 'easeOutBounce', function () {
                $(this).removeClass('anmaite_img').addClass('bgn').delay(1400).animate({
                    top: '-200px',
                    opacity: 0
                }, 1000, 'easeInOutElastic');
            });
            $('.anmaite_img .imga5').stop().delay(500).animate({
                marginTop: 0,
                opacity: 1
            }, 1000, 'easeOutBounce', function () {
                $(this).removeClass('anmaite_img').addClass('bgn').delay(1500).animate({
                    bottom: '-200px',
                    opacity: 0
                }, 1000, 'easeInOutElastic');
            });
            $('.anmaite_img .imga6').stop().delay(600).animate({
                bottom: 0,
                opacity: 1
            }, 1000, 'easeOutBounce', function () {
                $(this).removeClass('anmaite_img').addClass('bgn').delay(1600).animate({
                    top: '-200px',
                    opacity: 0
                }, 1000, 'easeInOutElastic');
            });
            $('.anmaite_img .imga7').stop().delay(700).animate({
                marginTop: 0,
                opacity: 1
            }, 1000, 'easeOutBounce', function () {
                $(this).removeClass('anmaite_img').addClass('bgn').delay(1500).animate({
                    bottom: '-200px',
                    opacity: 0
                }, 1000, 'easeInOutElastic');
            });

            setTimeout(function () {
                $('.index_anmaite').hide();
            }, 4000)
        }
    }
    var swiper = new Swiper('.Team_member .swiper-container', {
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',
        slidesPerView: 3,
        spaceBetween: 30,
        freeMode: false,
        loop: true,
        autoplay: 4000,
        autoplayDisableOnInteraction: true,
    });
    $('.btn').click(function () {
        $(this).toggleClass('active');
    })
    var myVideo = document.getElementById("video");
    var btn = document.getElementById("btn_play");
    $(btn).click(function () {
        var state = $('.btn').attr('state');
        if (state == '1') {
            $('.btn').attr('state', '0');
            myVideo.muted = true;
        } else if (state == '0') {
            $('.btn').attr('state', '1');
            myVideo.muted = false;
        }
    })
});
